@REM
@REM Copyright (c) Microsoft Corporation.  All rights reserved.
@REM
@REM
@REM Use of this sample source code is subject to the terms of the Microsoft
@REM license agreement under which you licensed this sample source code. If
@REM you did not accept the terms of the license agreement, you are not
@REM authorized to use this sample source code. For the terms of the license,
@REM please see the license agreement between you and Microsoft or, if applicable,
@REM see the LICENSE.RTF on your install media or the root of your tools installation.
@REM THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES OR INDEMNITIES.
@REM
@REM
@REM (C) Copyright 2006 Marvell International Ltd.
@REM All Rights Reserved
@REM
@echo off

if /i not "%MAKEIMG_BIN_FORMAT%"=="imageupdate" goto :end

if /i "%BSP_NONAND%"=="1" goto :nor
if /i not "%BSP_NAND_LARGEBLOCK%"=="" goto :nand_lb

:nand
echo NAND
echo Merging IPL and Image to create diskimage.nb0
copy /b %_FLATRELEASEDIR%\mobm_bc.nb0 + %_FLATRELEASEDIR%\eboot.nb0 + %_FLATRELEASEDIR%\ipl.nb0 %_FLATRELEASEDIR%\BootImage.nb0
copy /b %_FLATRELEASEDIR%\mobm_bc.nb0 + %_FLATRELEASEDIR%\secure_eboot.nb0 + %_FLATRELEASEDIR%\ipl.nb0 %_FLATRELEASEDIR%\SecureBootImage.nb0
goto complete

:nand_lb
echo MOBMV3 NAND Largeblock for Mh-LV. Will directly use OBM binary from OBM team, after pad it to 128KB size.
%_FLATRELEASEDIR%\bincut %_FLATRELEASEDIR%\NTIM_LV.bin %_FLATRELEASEDIR%\NTIM_LV_pad.bin 0 131072 -p0xff
%_FLATRELEASEDIR%\bincut %_FLATRELEASEDIR%\MHLV_wince_NTOBM.bin %_FLATRELEASEDIR%\MHLV_wince_NTOBM_pad.bin 0 131072 -p0xff
echo Merging NTIM_LV, OBM, Eboot, IPL to create bootimage.nb0
if /i "%BSP_DDR128MB%"=="1" goto :MOBMV3_LV_LARGE_NAND_128MB
copy /b %_FLATRELEASEDIR%\NTIM_LV_pad.bin + %_FLATRELEASEDIR%\MHLV_wince_NTOBM_pad.bin + %_FLATRELEASEDIR%\eboot.nb0 + %_FLATRELEASEDIR%\ipl.nb0 %_FLATRELEASEDIR%\BootImage.nb0
copy /b %_FLATRELEASEDIR%\NTIM_LV_pad.bin + %_FLATRELEASEDIR%\MHLV_wince_NTOBM_pad.bin + %_FLATRELEASEDIR%\secure_eboot.nb0 + %_FLATRELEASEDIR%\ipl.nb0 %_FLATRELEASEDIR%\SecureBootImage.nb0
goto complete
:MOBMV3_LV_LARGE_NAND_128MB
%_FLATRELEASEDIR%\bincut %_FLATRELEASEDIR%\MHLV_wince_NTOBM_128MBDDR.bin %_FLATRELEASEDIR%\MHLV_wince_NTOBM_128MBDDR_pad.bin 0 131072 -p0xff
copy /b %_FLATRELEASEDIR%\NTIM_LV_pad.bin + %_FLATRELEASEDIR%\MHLV_wince_NTOBM_128MBDDR_pad.bin + %_FLATRELEASEDIR%\eboot.nb0 + %_FLATRELEASEDIR%\ipl.nb0 %_FLATRELEASEDIR%\BootImage.nb0
copy /b %_FLATRELEASEDIR%\NTIM_LV_pad.bin + %_FLATRELEASEDIR%\MHLV_wince_NTOBM_128MBDDR_pad.bin + %_FLATRELEASEDIR%\secure_eboot.nb0 + %_FLATRELEASEDIR%\ipl.nb0 %_FLATRELEASEDIR%\SecureBootImage.nb0

goto complete

:nor
echo NOR
echo Merging IPL and Image to create diskimage.nb0
copy /b %_FLATRELEASEDIR%\ipl.nb0 + %_FLATRELEASEDIR%\flash.nb0 %_FLATRELEASEDIR%\diskimage.nb0
del %_FLATRELEASEDIR%\flash.nb0
goto complete

:complete
echo Complete
if NOT %ERRORLEVEL%==0 goto end

:end
if "%MAKEIMG_NEXT_CMD%" NEQ "" exit %ERRORLEVEL%
exit /B %ERRORLEVEL%
